package one;

/**
 * 1.简单工厂模式
 * 使用场景:通过工厂类创建实例的过程
 */
public class OperationFactory {
    public static Operation  createOperation(String operat){
        Operation operation=null;
        switch (operat){
            case "+":
                operation=new AddOperation();
                break;
            case "-":
                operation=new SubOperation();
                break;
            case "*":
                operation=new MulOperation();
                break;
            case "/":
                operation=new DivOperation();
                break;
        }
        return operation;
    }
}
